﻿@model Tyshka.Subroutines.ViewModels.SubEditModel

@{
    ViewBag.Title = "SubEditModel";
}

<div class="row">
	<div class="span8">
		<div class="bright_block">
			<div class="row">
				<div class="span5">
					<h1>Edit Subroutine Form</h1>				
				</div>
			</div>

		</div>

		<div class="bright_block">
			<h4>Disclaimer</h4>
			<div class="alert alert-block">
				<h4 class="alert-heading">License notes</h4>
				By uploading a piece of code into our system, you confirm that you have rights to distribute this code, and you confirm that you agree to distribute it under the terms and conditions of <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons - Attribution license</a>.	
			</div>
		</div>
	</div>

	<div class="span4 dcpu_logo">
		<!-- -->
	</div>
</div>

<div class="row">
	<div class="span12">
		<div class="bright_block">
            <h2>Edit Subroutine <small>Fill in the form to add/edit subroutine</small></h2>
         	<form class="form-horizontal" method="post" action="@Url.Action("Submit","Subroutine")">
            	<fieldset>
                    @Html.Hidden("id", Model.Id)
                    @Html.TextInput("Subroutine Name", "SubroutineName", String.Empty, Model.Name)
                    @Html.TextInput("Tags", "TagList", "Tags separated by comma", Model.TagLine)
                    <div class="control-group">
					    <label class="control-label" for="Description">Description</label>
					    <div class="controls">
						    <textarea class="input-xlarge" id="Description" name="Description" rows="7" >@(Model.Description ?? String.Empty)</textarea>
						    <span class="help-inline">Short description of purpose</span>
					    </div>
										
				    </div>
				    <div class="control-group">
					    <label class="control-label" for="Code">Code</label>
					    <div class="controls">
						    <textarea class="input-xlarge" id="Code" name="Code" rows="7">@(Model.Code ?? String.Empty)</textarea>
					    </div>
										
				    </div>
									
				    <div class="row">
					    <div class="span6 half_of_form">	
						    <h4>Input register parameters</h4>
						    <table class="table">
							    <thead>
								    <tr>
									    <th>Used</th>
									    <th>Register</th>
									    <th>Comment</th>														
								    </tr>
							    </thead>
							    <tbody>
                                    @foreach (var register in Model.InputRegisters)
                                    {
                                        @Html.InputRegisterRow(register)
                                    }	
							    </tbody>
						    </table>
											
											
					    </div>
					    <div class="span5">
						    <h4>Input stack parameters</h4>
							<table class="table">
							    <thead>
								    <tr>
									    <th>SP offset</th>
									    <th>Comment</th>
								    </tr>
							    </thead>
							    <tbody>
                                    @foreach (var stck in Model.Stacks)
                                    {
                                        @Html.StackParameterEditRow(stck.Offset, stck.Comment)
                                    }
							    </tbody>
						    </table>
					    </div>
				    </div>
									
			        <h4>Output register parameters</h4>
					<table class="table">
						<thead>
							<tr>
								<th>Used</th>
								<th>Register</th>
								<th>Comment</th>														
							</tr>
						</thead>
						<tbody>
							@foreach (var register in Model.OutputRegisters)
                            {
                                @Html.OutputRegisterRow(register)
                            }										
						</tbody>
					</table>
								
					<div class="form-actions">
						<input type="submit" class="btn btn-large btn-primary" value="Submit">
					    <a href="@Url.Action("Index", "Subroutine")" class="btn btn-large" >Back to Listing</a>
				    </div>  
			    </fieldset>   
            </form>
        </div>
    </div>
</div>
